<template>
  <div class="companycontent">
    <!--公司详情-->
    <div class="page-container">
      <div class="container">
        <div class="row">
          <!--左边-->
          <div class="span8 page-content">
            <el-page-header @back="$router.back(-1)" :content="content.company_name"></el-page-header>
            <article class="type-post format-standard hentry clearfix">
              <div>
                <div class="show_unit fl ativity">
                  <a class="iconfont ic">&#xe679;</a>
                  <a class="tagname">公司规模:</a>
                  {{content.company_scale}}
                </div>
                <div style="clear:both"></div>
                <!--占位-->
              </div>
              <h3>公司介绍</h3>
              <pre v-html="content.company_content"></pre>
              <h3>岗位列表</h3>
              <div v-for="(job,id) in joblist" :key="id" style="position:relative">
                <el-divider></el-divider>
                <router-link :to="'/jobcontent/'+job.job_id">
                  <h4>{{job.job_name}}</h4>
                </router-link>
                <h4 style="position: absolute;right: 40px; top: 5px; color:red">{{job.job_salary}}</h4>
              </div>
              <el-divider></el-divider>
            </article>
            <div class="like-btn">
            </div>
            <comment/>
          </div>
          <!--右边-->
          <aside class="span4 page-sidebar">
            <carousel/>
            <company/>
          </aside>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
import company from '../../components/company.vue'
import comment from '../../components/comment.vue'
import carousel from '../../components/carousel.vue'
import { mapState, mapActions } from 'vuex'
export default {
  name: 'companycontent',
  components: { company, comment, carousel },
  data () {
    return {
      dialogFormVisible: false, // 弹框相关
      content: {},
      announcementlist: {},
      joblist: []
    }
  },
  props: {
    id: {}
  },
  computed: {
    ...mapState({
      contentuserid: state => state.contentuserid,
      commentnum: state => state.commentnum
    })
  },
  methods: {
    ...mapActions(['setcontentid', 'setcontentinfo']),

    async getcompanycontent () {
      const data = {
        id: this.id
      }
      const result = await this.$axios.post('/web/getcompanycontent', this.qs.stringify(data))
      if (result.data.state.type === 'SUCCESS') {
        this.content = result.data.data.company
        this.joblist = result.data.data.joblist
        this.setcontentinfo({
          contentname: result.data.data.company.company_name,
          contentuserid: result.data.data.company.user_id
        })
      }
    }
  },
  watch: {
    id: {
      handler (newVal) {
        this.getcompanycontent()
        this.setcontentid(this.id)
      },
      deep: true,
      immediate: true
    }
  },
  created () {
    this.setcontentid(this.id)
  }
}
</script>

<style scoped>

</style>
